<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="p" uri="/WEB-INF/tld/page.tld" %>
<!DOCTYPE html>

<!--[if IEMobile 7]><html class="no-js iem7 oldie"><![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html class="no-js ie7 oldie" lang="en"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js ie8 oldie" lang="en"><![endif]-->
<!--[if (IE 9)&!(IEMobile)]><html class="no-js ie9" lang="en"><![endif]-->
<!--[if (gt IE 9)|(gt IEMobile 7)]><!--><html class="no-js" lang="en"><!--<![endif]-->

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

	<title>文化创意产业项目虚拟仿真实验教学系统</title>
	<%@include file="/header.jsp" %>
	<script type="text/javascript" src="/js/init.js"></script>
	<script type="text/javascript">
		var modal;
		$(function() {
			activeMenu(2);
		})
		
		function msgDialog(id) {
			var title,url1,url2;
			if(id==null) {
				title = "新建消息";
				url1 = "/msg/addMsg?isProMsg=${param.isProMsg}";
				url2 = "/msg/saveMsg";
			} else {
				title = "编辑消息";
				url1 = "/msg/loadMsg/"+id;
				url2 = "/msg/update";
			}
			modal = $.modal({
				title: title,
				url: url1,
				width: 750,
				ajax: {
					success: function()
					{
						modal.centerModal();
					}
				},
				buttons: {
					'保存': {
						classes: 'small blue-gradient glossy center',
						click: function(win) {
							$.ajax({
								url:url2,
								type:"post",
								data:$("#msg-form").serialize()+"&msg.content="+CKEDITOR.instances.ckeditor.getData(),
								dataType:"json"
							}).done(function(data){
								myalert(data.msg, function() {
									if(data.isSuccess) {
										win.closeModal();
										window.location = window.location;
									} 
								});
							})
						}
					},
					'关闭': {
						classes: 'small blue-gradient glossy center',
						click: function(win) {
							win.closeModal();
						}
					}
				}
			});
		}
		
		function publish(id) {
			$.ajax({
				url:"/msg/publish/"+id,
				dataType:"json"
			}).done(function(data){
				myalert(data.msg, function() {
					if(data.isSuccess) {
						window.location = window.location;
					}
				});
			})
		}
		
		function delMsg(id) {
			myconfirm("确定要删除？", function() {
				$.ajax({
					url:"/msg/delMsg/"+id,
					dataType:"json"
				}).done(function(data){
					myalert(data.msg, function() {
						if(data.isSuccess) {
							window.location = window.location;
						}
					});
				})
			})
		}
		
		function viewMsg(id) {
			modal = $.modal({
				title: "查看消息",
				url: "/msg/loadMsg/"+id+"?oper=view",
				width:750,
				ajax: {
					success: function()
					{
						modal.centerModal();
					}
				},
				buttons: {
					'关闭': {
						classes: 'small blue-gradient glossy center',
						click: function(win) {
							win.closeModal();
						}
					}
				}
			});
		}
	</script>
</head>

<body class="clearfix with-menu with-shortcuts">

	<!-- Prompt IE 6 users to install Chrome Frame -->
	<!--[if lt IE 7]><p class="message red-gradient simpler">Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->

	<!-- Title bar -->
	<header role="banner" id="title-bar">
		<h2>文化创意产业项目虚拟仿真实验教学系统</h2>
	</header>

	<!-- Button to open/hide menu -->
	<a href="#" id="open-menu"><span>Menu</span></a>

	<!-- Button to open/hide shortcuts -->
	<a href="#" id="open-shortcuts"><span class="icon-thumbs"></span></a>

	<!-- Main content -->
	<section role="main" id="main">

		<noscript class="message black-gradient simpler">Your browser does not support JavaScript! Some features won't work as expected...</noscript>

		<hgroup id="main-title" class="thin">
			<c:choose>
				<c:when test="${param.isProMsg eq 1 }">
					<h1>项目信息发布列表</h1>
				</c:when>
				<c:otherwise>
					<h1>系统信息发布列表</h1>
				</c:otherwise>
			</c:choose>
		</hgroup>

		<div class="with-padding">
		<div>
			<div class="dataTables_header">
				<div id="sorting-advanced_length" class="dataTables_length">
					<button class="button blue-gradient glossy" onclick="msgDialog();">新建</button>
				</div>
			</div>
			<table class="table responsive-table" id="msg-table">

				<thead>
					<tr>
						<th scope="col">标题</th>
						<th scope="col">分类</th>
						<th scope="col">日期</th>
						<th scope="col">操作</th>
					</tr>
				</thead>

				<tbody>
					<c:forEach items="${msgPage.list }" var="msg">
						<tr>
							<td>${msg.title }</td>
							<td>${msg.type_display }</td>
							<td>${msg.create_time }</td>
							<td class="low-padding">
								<span class="button-group compact">
									<a href="javascript:;" class="button" onclick='viewMsg("${msg.id}")'>查看</a>
									<a href="javascript:;" class="button" onclick='msgDialog("${msg.id}")'>修改</a>
									<a href="javascript:;" class="button" onclick='delMsg("${msg.id}")'>删除</a>
									<c:if test="${msg.status eq 0 }">
										<a href="javascript:;" class="button" onclick='publish("${msg.id}")'>发布</a>
									</c:if>
								</span>
							</td>
						</tr>
					</c:forEach>
					
				</tbody>

			</table>

			<div class="dataTables_footer">
				<div class="dataTables_info" id="sorting-advanced_info">
					第${msgPage.pageNumber }/${msgPage.totalPage }页,共${msgPage.totalRow }条记录
				</div>
				<p:page totalRow="${msgPage.totalRow }" pageNumber="${msgPage.pageNumber }"
					 totalPage="${msgPage.totalPage }"></p:page>
			</div>
		</div>
		</div>
	</section>
	<!-- End main content -->

	<script>

		// Call template init (optional, but faster if called manually)
		$.template.init();
		
	</script>
</body>
</html>